<!DOCTYPE html>
<!--学生  个人信息维护页面-->
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>个人信息维护</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="static/css/layui.css" media="all">
  <link rel="stylesheet" href="static/layuiadmin/style/admin.css" media="all">
<!--  <script src="static/js/jquery-2.1.3.min.js"></script>-->
</head>
<body>

<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>信息管理</cite></a>
    <a><cite>个人信息维护</cite></a>
  </div>
</div>

<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-header card-title">个人信息维护</div>
        <div class="layui-card-body">
          <table class="layui-hide" id="test-table-cellEdit" lay-filter="test-table-cellEdit"></table>
        </div>
      </div>
    </div>
  </div>
</div>

<script src="static/layui.js"></script>
<script th:inline="none">
  layui.config({
    base: 'static/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'table','form'], function(){
    var $ = layui.$;
    var table = layui.table;
    var form = layui.form;
    var exportData;
    var loading = layer.load();
    var ins1 = table.render({

      elem: '#test-table-cellEdit'
      ,method:'post'
      , url: '/selectgrxxwh'
      , cols: [[
        {field: 'sname', title: '学生姓名', width: 120, sort: true},
        {field: 'idcard', title: '学号', width: 180},
        {field: 'sex', title: '性别', width: 120, sort: true},
        {field: 'birth', title: '生日', width: 120, sort: true},
        {field: 'zid', title: '所属专业', width: 120, sort: true},
        {field: 'cid', title: '所属班级', width: 120, sort: true},
        {field: 'tel', title: '电话', width: 120, edit: 'text', sort: true},
        {field: 'jl', title: '简历', width: 120, edit: 'text', sort: true}
      ]]
      , done: function (res, curr, count) {
        layer.close(loading);
        exportData = res.data;
      }
    })

    //监听单元格编辑
    table.on('edit(test-table-cellEdit)', function(obj){
      var value = obj.value //得到修改后的值
              ,data = obj.data //得到所在行所有键值
              ,field = obj.field; //得到字段
        if(value==''){
          layer.msg('所改值不能为空',{icon:2});
          setTimeout(function(){
            window.location.reload();//修改成功后刷新父界面
          }, 1000);
        }
        else{
          $.ajax({
            url:"/upgrxxwh",
            data:{id:data.id , field:field,updateValue:value},
            type:"post",
            dataType:"json",
            success: function (result) {
              layer.msg('修改成功',{icon:1});
            },
            error:function (e) {
              layer.msg('修改失败',{icon:2});
            }
          })
        }
    });
  });

</script>
</body>
</html>